package com.cmcc.linlaker.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.cmcc.linlaker.R;


public class ToastUtils extends Toast {

    public ToastUtils(Context context) {
        super(context);
    }

    public static void showText(Context context, CharSequence text) {
        Toast result = new Toast(context);

        // 获取LayoutInflater对象
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        // 由layout文件创建一个View对象
        View layout = inflater.inflate(R.layout.toast_view, null);

        // 实例化ImageView和TextView对象
        TextView textView = (TextView) layout.findViewById(R.id.text_content);
        textView.setText(text);

        result.setView(layout);
        int bottomMargin = DensityUtil.dip2px(context, 150);
        result.setGravity(Gravity.BOTTOM, 0, bottomMargin);
        result.setDuration(Toast.LENGTH_SHORT);
        result.show();
    }

}